import csv
import json
import re

#正则获取token的值
def get_str_by_re(left='\\A',right='\\Z',string=''):
    result=re.search(f'{left}(.*?){right}',string)  # ？非贪婪模式，匹配最少得内容
    #result=re.search('{}(.*?){}'.format(left,right),string) #python3.5以下版本使用这个
    return result.group(1)
##定义一个函数获取cev文件内容
def get_csv():
    file=csv.reader(open(r'D:\work\python_files\seafile_128\data\name_years.csv',encoding='gbk'))
    list_file=[]
    for i in file:
        # print(i)
        list_file.append(i)
    else:
        return list_file
def get_csv_data(path):
    file=csv.reader(open(path,encoding='utf-8'))
    list_file=[]
    for i in file:
        # print(i)
        list_file.append(i)
    else:
        return list_file


# 定义一个函数获取json文件内容
def get_json():
    # files=open(r'D:\work\python_files\seafile_128\data\number.json',encoding='utf-8').read()
    number=json.loads(open(r'D:\work\python_files\seafile_128\data\number.json',encoding='utf-8').read())
    print(number)
    return number

## 获取自定义的csv文件输入
def get_default_file():
    file=csv.reader(open('D:\work\python_files\seafile_128\data\default_file.csv',encoding='utf-8'))
    file_list=[]
    for i in file:
        file_list.append(i)
    else:
        # print(file_list)
        return file_list
if __name__ == '__main__':
    get_default_file()
